<extend name="Layout:default"/>
<block name="title"><title>重设密码</title></block>
<block name="style">
<css href="/Public/Assets/Hui/lib/validator/jquery.validator.css"/>
<css href="/Public/Assets/Hui/lib/icheck/icheck.css"/>
<style>

</style>
</block>

<block name="main">
<div class="container clearfix">
	<div id="content-container">
		<div class="login-section" id="tab_register" class="HuiTab">
			  <div class="login-tab2 cl">重设密码</div>
			  <div class="login-tab3 cl"><a href="{:U('resetpwd')}">手机号码</a><a href="javascript:;" class="active">邮箱设置</a></div>
			  <div class="login-con">
			  <form action="{:U('emailforpwd_post')}" method="post" class="validator_form">
			  	<div class="control-group mb-30">
			  		<label class="formlabel" for="">邮箱</label>
					<div class="formControls">
						<input type="text" class="input-text radius  size-L" value="" placeholder="email"  name="email" data-rule="邮箱:required; email; remote[/users/login/checkhas/t/email]">
					</div>
			  	</div>
			  	<div class="control-group mb-40">
			  		<div class="formControls">
			  			<input class="btn btn-primary btn-block radius size-L" type="submit" id="emailforpwd" value="发送邮件">
			  		</div>
			  	</div>
			  </form>
			  <div class="mb-40"><a href="{:U('index')}">返回登录</a></div>
		</div>
		</div>
	</div>
</div>
</block>

<block name="script">
<js href="/Public/Assets/Hui/lib/validator/jquery.validator.js"/>
<js href="/Public/Assets/Hui/lib/validator/local/zh_CN.js"/>
<js href="/Public/Assets/Hui/lib/icheck/jquery.icheck.min.js"/>
<js href="/Public/Sea/modules/layer/2.1/layer/layer.js"/>
<script>
$('.validator_form').validator({
		msgClass: "n-bottom", 
		msgIcon:"",
  	    valid: function(form){
  	    	var me = this;
  	    	//防止重复提交表单
  	        me.holdSubmit();
  	        var ii = layer.msg('数据处理中...', {icon: 16,time: 10000}, function(){
	    	    layer.alert('服务器响应超时', {icon: 7});
	    	});
  	     	$.ajax({
	            url:  $(form).attr('action'),
	            data: $(form).serialize(),
	            type: "POST",
	            dataType:"json",
	            success: function(data){
	            	layer.close(ii);
	            	//data = JSON.parse(data);  //str 转 json
	            	if (data.status==1) {
	            		layer.msg(data.info, {icon: 1,time:1000});
	                }else{
	                	layer.msg(data.info, {icon: 2,time:1000});
	                }
	            	//需要跳转的话
	            	if(data.url){
	                   	setTimeout(function(){
	                   		location.href= data.url;
	                   	},1000);
	                   }
	            	
	            	//信息提示框结束之后，表单可提交
	            	setTimeout(function(){
	            		me.holdSubmit(false);
	                 },1000);
	            	
	            }
        	});
  	   	}
});
</script>
</block>